
package model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class SuratDokumenTableModel extends AbstractTableModel {

    String columNames[] = {"ID_SRTDOK", "TGL_TERIMA", "NO_SURAT", "NO_DOKUMEN", "PRIHAL", "PENGIRIM", "PENERIMA", "TANGGAL_TERIMA", "PETUGAS_PENERIMA", "TEMPAT_PENYIMPANAN"};
    private ArrayList<SuratDokumen> dataSD;
    private ArrayList<Surat> dataS;
    private ArrayList<Dokumen> dataD;

    public SuratDokumenTableModel() {
    }

    public SuratDokumenTableModel(ArrayList<SuratDokumen> dataSD) {
        this.dataSD = dataSD;
    }

    @Override
    public int getRowCount() {
        return getDataSD().size();
    }

    public int getRowCountS() {
        return getDataS().size();
    }

    public int getRowCountD() {
        return getDataD().size();
    }

    @Override
    public int getColumnCount() {
        return columNames.length;
    }

    @Override
    public String getColumnName(int col) {
        return columNames[col];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        SuratDokumen tempSD = getDataSD().get(rowIndex);
        Surat tempS = getDataS().get(rowIndex);
        Dokumen tempD = getDataD().get(rowIndex);
        if (columnIndex == 0) {
            return tempSD.getIdSuratDokumen();
        } else if (columnIndex == 1) {
            return tempSD.getTanggalSuratDokumen();
        } else if (columnIndex == 2) {
            return tempS.getNoSurat();
        } else if (columnIndex == 3) {
            return tempD.getNoDokumen();
        } else if (columnIndex == 4) {
            return tempSD.getPerihal();
        } else if (columnIndex == 5) {
            return tempSD.getPengirim();
        } else if (columnIndex == 6) {
            return tempSD.getPenerima();
        } else if (columnIndex == 7) {
            return tempSD.getTanggalDiterima();
        } else if (columnIndex == 8) {
            return tempSD.getPetugasPenerima();
        } else {
            return tempSD.getTempatPenyimpanan();
        }
    }

    public ArrayList<SuratDokumen> getDataSD() {
        return dataSD;
    }

    public ArrayList<Surat> getDataS() {
        return dataS;
    }

    public ArrayList<Dokumen> getDataD() {
        return dataD;
    }

    public void setDataSD(ArrayList<SuratDokumen> dataSD) {
        this.dataSD = dataSD;
    }

    public void setDataS(ArrayList<Surat> dataS) {
        this.dataS = dataS;
    }

    public void setDataD(ArrayList<Dokumen> dataD) {
        this.dataD = dataD;
    }
}
